$(function(){
    $('body').on('touchmove', function (event) {
        event.preventDefault();
    });

    $('.reload').click(function(){
        var urls = $(".reload").attr("src");
        $(".reload").attr("src",urls+'?tm='+Math.random());
    });

    $(".form-control").keyup(function(e){
        if(e.keyCode === 13){
            $(".ajax-post").click();return;
        }
    });

    $(".inside-block").niceScroll({
        cursorcolor: "#000",
        zindex: 999,
        bouncescroll: true,
        cursoropacitymax: 0.4,
        cursorborderradius: 8,
        cursorwidth: "6px",
        background: "rgba(0,0,0,.1)",
        autohidemode: false,
        railpadding: {
            top: 0,
            right: 2,
            left: 2,
            bottom: 0
        }
    });

    $('.ajax-post').click(function(){
        var loading;
        $.ajax({
            type: "POST",
            dataType: "json",
            url: $('.FormTable').action,
            data: $('.FormTable').serialize(),
            beforeSend:function(){
                $('.reload').click();
                loading = layer.load(1,{
                    shade: [0.7,'#000']
                });
            },success:function(data){
                layer.close(loading);
                if(data.Code == 1){
                    layer.msg(data.Msgs,{icon: 1,time: data.Wait});
                }else{
                    layer.msg(data.Msgs,{icon: 2,time: data.Wait});
                }
                if(data.Urls){
                    window.setTimeout(function(){
                        window.location.href = data.Urls;
                    },data.Wait);
                }
            },error:function(){ 
                layer.close(loading);
                layer.open({
                    icon: 7,
                    title: "系统提示",
                    content: "网络错误"
                });
            }
        });
    });
});